<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>支付页面 - 小憨堡</title>
    <script src="../static/js/jquery-3.2.1.js"></script>
    <link rel="stylesheet" href="../static/bootstrap-3.3.7-dist/css/bootstrap.css" />
    <link rel="stylesheet" href="../static/css/style.css" />
    <script>
        function pay() {
            $.get(
                "/order/list",
                function (data, status) {
                    if (data.code == 0) {
                        $.ajax({
                            url: "/order/create",
                            type: "post",
                            contentType: "application/json",
                            data: JSON.stringify(data.data),
                            success: function (data1, status) {
                                if (data1.code == 0) {
                                    var orderId = data1.data;
                                    window.location = "/order/pay?orderId=" + orderId;
                                }
                            }
                        });
                    } else {
                        alert("获取商品列表失败！");
                    }
                }
            );
        }
    </script>
</head>
<body>
    <button class="btn btn-info btn-pay col-md-2" onclick="pay()">立刻支付</button>
</body>
</html>